﻿package classes 
{
	import classes.*;
	import commands.*;
	
	/**
	 * ...
	 * @author wwx
	 */
	public class Command 
	{
		
		public function Command() 
		{
			
		}
		
		private var m_callbackFun:Function = null; 
		
		private var m_tcpSocket:TCPSocket;
		
		
		private function recvDataCallback():void
		{
			var cmdLen:int = 0;
			var recvLen:int = 0;
			var header:ByteArray = new ByteArray;
			recvLen = m_tcpSocket.recv(header, 0, 4);
			if (4 != recvLen)
			{
				trace("recvDataCallback error! " + recvLen);
				return ;
			}
			
			cmdLen = header[0] + ((int(header[1])) << 8) + ((int(header[2])) << 16) + ((int(header[3])) << 24);
			
			var cmdBuffer:ByteArray = new ByteArray();
			
			recvLen = m_tcpSocket.recv(cmdBuffer, 0, cmdLen);
			if (recvLen != cmdLen)
			{
				trace("recvDataCallback error2!");
				return ;
			}
			
			trace("recv cmd! " + recvLen);
		}
	}
	
}